import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
import utils.JsonMap;
import java.io.File;
import java.io.IOException;

public class GlobalProcessing {
    public static void main(String[] args) {
        String inputFile = "D:\\code\\hdfork\\archguard\\server\\dependencies\\codeCrop.json";
        String outputFile = "D:\\code\\hdfork\\archguard\\server\\dependencies\\outputChain.json";

        ObjectMapper mapper = new ObjectMapper();

        // 解析为可修改的ObjectNode
        ObjectNode root = null;
        try {
            root = (ObjectNode) mapper.readTree(new File(inputFile));
            // 1、移除部分位置字段
            JsonMap.removePositionFields(root);
            // 2、处理链式节点,方法调用连接
            JsonMap.processChainNodes(root, root);
            // 执行节点拆分
//            JsonNode extracted = splitNode(root, "targetNode");
            // 输出结果
            mapper.writerWithDefaultPrettyPrinter().writeValue(new File(outputFile), root);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}
